07 Jan 2021

What is git?

“You use Git to take snapshots of all the files in a folder.”

Alice Bartlett


Snapshots in time

Three key concepts


  • Repository - your project folder
  • Commit - a snapshot of your folder
    • We use push to send the snapshots online
    • And pull to retrieve an updated snapshot
  • Branch - a working version of your folder

Work git!

Installing git


  • For Windows, download the executable here
  • On a mac type git --version in your terminal
  • On linux machines type sudo apt install git-all in your terminal


Note that you may need admin rights on your computer, without these you’ll need to request an install.

Create a GitHub account


GitHub offers a range of account types. A free account is available for organisations and individuals.

Even if you’re in an institution, create a personal GitHub account to keep track of you own work.

You’ll find more information, and links for creating an account, here.

Create a repository

  • Follow the instructions here to create your first repository

  • Some key files to include:

    README - ideally format this as a markdown md file (more info here and here)

    LICENSE - how you want people to re-use your code (info)

    .gitignore - names of any files in your project you don’t want on GitHub (templates)

Linking to RStudio



  • Rstudio does a lot of the hard work for you
  • You can use the terminal, if you like
  • Here are some screenshots showing you how to link a GitHub repository to RStudio

Useful resources

  • Introduction to GitHub presentation (slides and video)
  • All you need to know about GitHub in their help pages
  • Detailed book about git, GitHub and R (here)
  • Detailed overview of RStudio, git and GitHub (here)
  • A game to help us think about git branches (here)
  • ONS GitHub introductory course (here)